package com.platform.usercenter.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.platform.basicdata.api.remote.RemoteBasicdataService;

import com.platform.common.core.domain.entity.SysDept;
import com.platform.common.core.domain.entity.SysRole;
import com.platform.common.core.domain.entity.SysUser;
import com.platform.common.core.enums.UserManagerEnum;
import com.platform.common.core.web.controller.BaseController;
import com.platform.common.core.web.domain.AjaxResult;

import com.platform.common.security.service.TokenService;
import com.platform.common.security.utils.SecurityUtils;
import com.platform.system.api.remote.api.RemoteSystemService;
import com.platform.usercenter.config.ConfigConstants;
import com.platform.usercenter.domain.SysOrganizationAdministrator;
import com.platform.usercenter.domain.SysUserDept;
import com.platform.usercenter.domain.query.SysRoleQuery;
import com.platform.usercenter.domain.query.SysUserDeptQuery;
import com.platform.usercenter.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;

/**
 * 用户信息公共接口
 *
 * @author
 */
@Slf4j
@RestController
@RequestMapping("/commonApi")
public class SysUserCommonController extends BaseController {

    @Resource
    private ISysUserCommonService commonService;


    @Resource
    private  ISysRoleService sysRoleService;



    /**
     * 查询用户组织下的角色关系列表（标准接口）
     * @return
     */
    @Deprecated
    @GetMapping("/getOrganizationalRole")
    public AjaxResult getOrganizationalRole(SysRoleQuery sysRoleQuery) {
        // 超管可以看见全部角色--判断是否为超管用户
        Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();

        if(!commonService.isAdmin(userId)){
            // 获取当前用户组织
            Long orgId = SecurityUtils.getLoginUser().getOrgId();
            sysRoleQuery.setOrgId(orgId);
            sysRoleQuery.setUserId(userId);
        }
        return AjaxResult.success(sysRoleService.selectRoleList(sysRoleQuery));
    }

    /**
     * 获取角色对应的功能权限集合（标准接口）
     */
    @Deprecated
    @GetMapping("/getRolePermission")
    public AjaxResult getRolePermission(){

        return AjaxResult.success();
    }
    /**
     * 获取用户所有功能权限的对应数据权限集合key-value（标准接口）
     * key来自字典表（跟业务来源有关），value来自基础数据表
     */
    @Deprecated
    @GetMapping("/getFunPermission")
    public AjaxResult getFunPermission(){

        return AjaxResult.success();
    }



}
